home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1995…tember: Reference Library / Dev.CD Sep 95 RL / Dev.CD Sep 95 RL.toast / mac / Technical Documentation / develop / develop Issue 22 code / PCI Driver Sample / NCR_DriverProject / Src / NCRDriverPrivate.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-04-08  |  10.2 KB  |  308 lines  |  [TEXT/MPCC]

  1. /*                                NCRSCSIDriverPrivate.h                                */
  2. /*
  3.  * NCRSCSIDriverPrivate.h
  4.  * Copyright © 1994 Apple Computer Inc. All rights reserved.
  5.  */
  6. /*    .___________________________________________________________________________________.
  7.       | This is a private interface file for the sample driver. It contains configuration    |
  8.     | parameters, driver-specific global definitions, and function prototypes.            |
  9.     | NCR chip specific information is in NCR53C825.h.                                    |
  10.     .___________________________________________________________________________________.
  11.  */
  12.  
  13. #ifndef __NCRSCSIDriverPrivate__
  14. #define __NCRSCSIDriverPrivate__
  15.  
  16. #define kVersionMajor        1
  17. #define kVersionMinor        0
  18. #define kVersionStage        beta                    /* Res only                        */
  19. #define kVersionStageLetter    'b'
  20. #define kVersionStageValue    betaStage                /* Beta                            */
  21. #define kVersionRevision    3
  22. /*
  23.  * Define the longest I/O transfer that the driver can perform. This determines the size
  24.  * of the physical mapping tables. (It's a define rather than an enum because it might 
  25.  * not fit into a C int).
  26.  */
  27. #if 1
  28. #define kNCRDriverMaxTransfer    (1024L * 1024L)        /* One Megabyte                    */
  29. #else /* Test partial preparation */
  30. #define kNCRDriverMaxTransfer    (4096L)                /* 4 Kb for partial prep test    */
  31. #endif
  32.  
  33. #define USE_LOG_LIBRARY            1                    /* Used for debugging            */
  34. #define LOG_TRACE                0                    /* Used for serious debugging    */
  35. /*
  36.  * Use MEM space until AAPL,addresses is available. AAPL,addresses is indeed
  37.  * available, but I haven't tested I/O accesses.
  38.  */
  39. #define USE_MEM_ACCESS            1    /* Algorithm Testing    */
  40. /*
  41.  * USE_LOG_LIBRARY is set non-zero to compile in debugging functions. It should be set
  42.  * FALS during the final stages of software testing. If you compile under MPW, you would
  43.  * probably use a value defined in the MakeFile.
  44.  *
  45.  * LOG_TRACE logs entrances to all significant functions.
  46.  */
  47. #ifndef USE_LOG_LIBRARY
  48. #define USE_LOG_LIBRARY            0
  49. #endif
  50. #ifndef USE_MEM_ACCESS
  51. #define USE_MEM_ACCESS            1
  52. #endif
  53. #ifndef LOG_TRACE
  54. #define LOG_TRACE                USE_LOG_LIBRARY
  55. #endif
  56.  
  57. /*
  58.  * TEST_DRIVER is set TRUE by the test function. When non-zero it blocks definition
  59.  * of the driver's chip-access functions.
  60.  */
  61. #ifndef TEST_DRIVER
  62. #define TEST_DRIVER                0
  63. #endif
  64. #ifndef FALSE
  65. #define TRUE    1
  66. #define FALSE    0
  67. #endif
  68.  
  69. #define kCreatorType                'PSSD'            /* Registered Creator Type        */
  70. #define kDriverGlobalsPropertyName    "DriverGlobals"    /* -> GLOBAL area                */
  71. #define kDriverFailurePropertyName    "InitFailure"    /* Gets status on init failure    */
  72. #define ICON_Driver                    128                /* File Bundle icon                */
  73. #define BNDL_Resource                128
  74. /*
  75.  * The driver name is defined in the public header
  76.  */
  77.  
  78. #define kAuditIdent        (kCreatorType)            /* Audit Gestalt Selector            */
  79. #define kAuditEntries    256
  80.  
  81. #ifndef REZ
  82. /*
  83.  * For code segments only
  84.  */
  85. /*
  86.  * Note: Do not use pre-compiled headers as they have not been upgraded for
  87.  * the PCI driver definitions.
  88.  *
  89.  * Note that we have expanded all #include files to pre-load all dependencies.
  90.  * If you add #include files, be sure to all their precedent files are loaded
  91.  * from the {CIncludes} folder that contains the current PCI headers. This will
  92.  * be revised when the PCI-headers are merged into the common Universal Header
  93.  * distribution.
  94.  *
  95.  * This must be changed when the PCI-specific headers are merged into the
  96.  * standard distribution.
  97.  */
  98.  
  99. #include <ConditionalMacros.h>
  100. #if GENERATINGPOWERPC == 0
  101.     << error: the following will not work >>
  102. #endif
  103. #include <Types.h>
  104. #include <MixedMode.h>
  105. #include <OSUtils.h>
  106. #include <Files.h>
  107. #include <QuickdrawText.h>
  108. #include <QuickDraw.h>
  109. #include <Events.h>
  110. #include <Errors.h>
  111. #include <Memory.h>
  112. #include <Menus.h>
  113. #include <Controls.h>
  114. #include <Windows.h>
  115. #include <TextEdit.h>
  116. #include <Dialogs.h>
  117. #include <MachineExceptions.h>
  118. #include <PCI.h>
  119. #include <Kernel.h>
  120. #include <NameRegistry.h>
  121. #include <CodeFragments.h>
  122. #include <Devices.h>
  123. #include <Fonts.h>
  124. #include <Resources.h>
  125. #include <LowMem.h>
  126. #include <DriverServices.h>
  127. #include <Interrupts.h>
  128. #include <SCSI.h>
  129. #if defined(powerc) || defined (__powerc)        //** TEMP
  130.  
  131. #if USE_LOG_LIBRARY
  132. #include "LogLibrary.h"
  133. #endif
  134.  
  135. /*
  136.  * Include the public header files and the NCR-specific headers.
  137.  */
  138. #include "NCRDriver.h"
  139. #include "NCR53C825.h"
  140.  
  141. /*
  142.  * The UNUSED macro replaces #pragma unused (x)
  143.  */
  144. #define UNUSED(what) do { what = what; } while (0)
  145.  
  146. /*
  147.  * kIOBusyStatus is returned to the Device Manager if an asynchronous I/O
  148.  * request is pending.
  149.  */
  150. enum {
  151.     kIOBusyStatus            = 1
  152. };
  153.  
  154. /*
  155.  * These are private OSErr values that are passed to the Secondary Interrupt
  156.  * handler to start or continue I/O
  157.  */
  158. enum {
  159.     kIORequestStart            = +1000,    /* DoDriverIO -> Start NCR device            */
  160.     kPrepareMemoryStartTask,            /* Primary Interrupt -> PrepMemory Task        */
  161.     kPrepareMemoryRestart,                /* PrepMemory Task -> Restart NCR device    */
  162.     kBusResetRestart                    /* BusReset interim interrupt -> Delay        */
  163. };
  164.  
  165. /*
  166.  * Defined PBControl csCodes. Note that we don't support all of these.
  167.  */
  168. enum {
  169.     kControlGoodbye            = (-1),        /* Last call before close (ignored)            */
  170.     kControlKillIO            = 1,        /* This is handled by the Driver Manager    */
  171.     kControlVerifyDisk        = 5,        /* Verify disk                                */
  172.     kControlFormatDisk        = 6,        /* Format disk                                */
  173.     kControlEjectDisk        = 7,        /* Eject disk (ejectable media only)        */
  174.     kControlPhysicalIcon    = 21,        /* Return physical icon and where string    */
  175.     kControlMediaIcon        = 22,        /* Return media icon                        */
  176.     kControlDriveInfo        = 23,        /* Return drive info                        */
  177.     kControlPartitionSize    = 24        /* SCSI partition size                        */
  178. };
  179.  
  180. /*
  181.  * Defined PBStatus csCodes..
  182.  */
  183. enum {
  184.     kStatusDriveStatus        = 8            /* Drive status    -- currently unused            */
  185. };
  186. /*
  187.  * Defined Driver Gestalt selectors.
  188.  */
  189. #pragma options align=mac68k
  190. #endif
  191. /*
  192.  * This is a temporary inclusion until driver gestalts are added to the system headers.
  193.  */
  194. #include "TempDriverGestalt.h"
  195. #if defined(powerc) || defined(__powerc)        //** TEMP
  196. #pragma options align=reset
  197. #endif
  198. enum {
  199.     /*
  200.       * Power management
  201.      */
  202.     kDriverGestaltPowerSwitch    = 'ptog',    /* Support Power up/down switching?        */
  203.     kDriverGestaltPowerMode        = 'psta',    /* TRUE if in high-power mode            */
  204.     kDriverGestalt5MaxHighPower    = 'pmx5',    /* Max 5 volt uAmps in high-power mode    */
  205.     kDriverGestalt5MaxLowPower    = 'pmn5',    /* Max 5 volt uAmps in low-power mode    */
  206.     kDriverGestalt3MaxHighPower    = 'pmx3',    /* Max 3 volt uAmps in high-power mode    */
  207.     kDriverGestalt3MaxLowPower    = 'pmn3'    /* Max 3 volt uAmps in low-power mode    */
  208. };
  209.  
  210. /*
  211.  * SCSI command status (from status phase). Before returning final status, the
  212.  * driver checks that the command status is "good" (zero) -- otherwise, if no
  213.  * other errors are detected, it returns scsiNonZeroStatus.
  214.  */
  215. enum {
  216.     kScsiCommandStatusGood                = 0x00,    /* Normal completion        */
  217.     kScsiCommandStatusCheckCondition    = 0x02,    /* Need GetExtendedStatus    */
  218.     kScsiCommandStatusConditionMet        = 0x04,
  219.     kScsiCommandStatusBusy                = 0x08,    /* Device busy (self-test?)    */
  220.     kScsiCommandStatusIntermediate        = 0x10,    /* Intermediate status        */
  221.     kScsiStatusResConflict                = 0x18,    /* Reservation conflict        */
  222.     kScsiStatusQueueFull                = 0x28,    /* Target can't do command    */
  223.     kScsiStatusReservedMask                = 0x3e    /* Vendor specific?            */
  224. };
  225.  
  226. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  227.  * Our global storage is defined by this structure. This is not a requirement of the
  228.  * driver environment, but it collects globals into a coherent structure for debugging.
  229.  */
  230. #pragma options align=power
  231. struct DriverGlobal {
  232.     /*
  233.      * When we support concurrent I/O, we will need several of these.
  234.      * The perRequestRecord is defined in NCR53C825.h
  235.      */
  236.     PerRequestDataPtr        perRequestDataPtr;        /* Script communication area        */
  237.     /*
  238.      * DriverRefNum and RegEntryID are passed to us by the driver initialize command.
  239.      */
  240.     DriverRefNum            refNum;                /* Driver refNum for PB...            */
  241.     RegEntryID                deviceEntry;        /* Name Registry Entry ID            */
  242.     /*
  243.      * GetPCICardBaseAddress initialzes pciCardBaseAddress when the driver starts.
  244.      * this is a logical address that will be used to access the NCR card registers.
  245.      */
  246.     LogicalAddress            pciCardBaseAddress;            /* To access NCR registers    */
  247.     /*
  248.      * Interrupt Set globals.
  249.      */
  250.     InterruptSetMember        interruptSetMember;            /* Interrupt set identifier    */
  251.     void                    *interruptSetRefcon;        /* Existing refCon            */
  252.     InterruptHandler        interruptServiceFunction;    /* -> old isr function        */
  253.     InterruptEnabler        interruptEnableFunction;    /* -> interrupt enabler        */
  254.     InterruptDisabler        interruptDisableFunction;    /* -> interrupt disabler    */
  255.     /*
  256.       * PrepareMemoryForIO globals:
  257.      * pageSize                Size of the system's physical page (== 4096)
  258.      * pageMask                Mask to get the offset within this page.
  259.      */
  260.     UInt32                    pageSize;                    /* GetLogicalPageSize()        */
  261.     UInt32                    pageMask;                    /* pageSize - 1                */
  262.     /*
  263.      * We need to stall 12 PCI clock ticks between some NCR register reads.
  264.      */
  265.     AbsoluteTime            clockTick12;                /* for DelayForHardware        */
  266.     AbsoluteTime            msec250;                    /* for Bus Reset delay        */
  267.     /*
  268.      * Information retrieved from the System Registry
  269.      */
  270.     UInt8                    initiatorID;                /* SCSI Bus ID                */
  271.     Boolean                    initiatorIsInNVRAM;            /* Fetched from NVRAM?        */
  272.     /*
  273.       * Script patching variables. The script is prepared when the driver is
  274.      * initialized. Preparation determines the physical addresses of the scripts.
  275.      * GLOBAL.scriptIOTable is prepared when the driver is opened, and checkpointen
  276.      * when the driver is closed.
  277.      */
  278.     IOPreparationTable        scriptIOTable;                /* Prepare for the script    */
  279. #if USE_LOG_LIBRARY
  280.     OSType                    logIdentifier;                /* Who am I (the refNum)    */
  281.     LogRecordPtr            logRecordPtr;                /* Logging driver reference    */
  282. #endif
  283.     /*
  284.      * These are only needed for debugging.
  285.      */
  286.     UInt32                    *ncrSCSIScript;                /* Our SCSI script                */
  287.     ByteCount                ncrSCSIScriptSize;            /* Script size in bytes            */
  288. };
  289. typedef struct DriverGlobal DriverGlobal, *DriverGlobalPtr;
  290. #pragma options align=reset
  291.  
  292. #if TEST_DRIVER == 0
  293. /*
  294.  * Globals and functions
  295.  */
  296. extern DriverGlobal        gDriverGlobal;                /* All interesting globals        */
  297. #define GLOBAL            (gDriverGlobal)                /* GLOBAL.field for references    */
  298. extern DriverDescription TheDriverDescription;        /* Exported to the universe        */
  299. extern UInt32            gNCRSCSIScript[];            /* Our SCSI script                */
  300. extern ByteCount        gNCRSCSIScriptSize;            /* Script size in bytes            */
  301.  
  302. #include "NCRDriverPrototypes.h"
  303.  
  304. #endif /* If not TEST_DRIVER */
  305. #endif /* If not REZ */
  306. #endif /* __NCRSCSIDriverPrivate__ */
  307.  
  308.